package com.aliyun.mts.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

public class AliyunConfig {

    public static String MTS_SERVER_URL;
    public static String ossEndPoint;
    public static String location;

    public static String waterMarkFilePath;

    public static String accessKeyId;// 访问阿里云秘钥id
    public static String accessKeySecret;// 访问阿里云秘钥Secret
    public static String pipelineId;// 管道ID
    public static String transcodeTemplateId;// 模板ID
    public static String waterMarkTemplateId;// 水印ID

    public static String inputBucket;
    public static String outputBucket;

    public static String bucketPath;
    public static String saveTMSPath;

    static {
        try {
            File file = new File(AliyunConfig.class.getClassLoader()
                    .getResource("resources/config/aliyun.properties")
                    .getPath());
            if (!file.exists()) {
                throw new RuntimeException(
                        "config/aliyunconfig.properties 配置文件不存在!");
            }
            FileInputStream fis = new FileInputStream(file);
            Properties properties = new Properties();
            properties.load(fis);
            Class configClazz = AliyunConfig.class;
            Field[] fields = configClazz.getDeclaredFields();
            for (Field f : fields) {
                f.set(configClazz, properties.getProperty(f.getName()));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws IOException {
        System.out.println(inputBucket);
    }
}